#!/bin/bash

topdir=$(dirname $(realpath $0))
BUILD_DIR=${topdir}/build

function build_check_env()
{
    if [ -z $X2500_TOOLCHAIN_PATH ];then
        echo "Please get the x2500_toolchains from Bashi Tech, and configure environment variables X2500_TOOLCHAIN_PATH like this:"
        echo "export X2500_TOOLCHAIN_PATH=\"/home/database/toolchains/x2500_toolchains\""
        exit 1
    fi
}

function build_target()
{
    echo ""
    pushd $topdir > /dev/null
    mkdir -p $BUILD_DIR
    cd $BUILD_DIR
    cmake ../
    make clean all
    popd > /dev/null
}

build_check_env
build_target
